package com.csg.ses.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.csg.ses.feign.DpssService;
import com.csg.ses.feign.PhpService;
import com.csg.ses.feign.ZncfFeign;
import com.csg.ses.service.ses.YxzjkZwCsxxService;
import com.csg.ses.vo.yxxt.YxxtInParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @auther wangjun
 * @time 2020/11/17 14:38
 */
@RestController
@RequestMapping("/test")
@ApiIgnore
public class TestController {

    @Autowired
    private DpssService dpssService;

    @Autowired
    private PhpService phpService;

    @Autowired
    private ZncfFeign zncfFeign;

    @Autowired
    private YxzjkZwCsxxService csxxService;

    @GetMapping("/dpss")
    public Object testDpss() {
        return dpssService.testDpss();
    }

    @GetMapping("/proc")
    public Object procTest() {
        Map<String, Object> param = new HashMap<>();
        param.put("in_yxpch", "00000213332");
        csxxService.p_handle_phone_numbers(param);
        System.out.println(param);
        return param;
    }

    @PostMapping("/dpss/login")
    public Object loginDpss(@RequestBody LinkedHashMap<String, String> login) {
        return dpssService.loginDpss(login);
    }

    @PostMapping("/vcs-token")
    public JSONObject getVcsToken() {
        String str = "{\"access\":\"test\",\"pass\":\"test2020\"}";
        JSONObject obj = JSON.parseObject(str);
        System.out.println(obj);
        ResponseEntity<String> exchange = phpService.getToken(obj);
        JSONObject jsonObject = JSON.parseObject(exchange.getBody());
        System.out.println(jsonObject);
        return jsonObject;
    }

    @PostMapping("/vcs-test")
    public JSONObject vcsTest() {
        JSONObject obj = new JSONObject();
        obj.put("access", "test");
        obj.put("pass", "test2020");

        JSONArray arr = new JSONArray();
        arr.add(obj);
        System.out.println(arr);

        return obj;
    }

    @GetMapping("/ttt")
    public JSONObject tttTest() {
        String str =
                "{\"info\":\"\",\"code\":0,\"data\":{\"list\":[{\"id\":\"1\",\"create_time\":\"2020-11-25\n" +
                        "16:46:28\",\"phone\":\"15088134190\",\"call_time\":\"2020-11-25\n" +
                        "16:48:31\",\"call_billsec\":\"0\",\"call_status\":\"3\",\"classification\":\"D\",\"anwser_time\":null,\"hangup_time\":\"2020-11-25\n" +
                        "16:48:32\",\"hangup_cause\":\"\\u547c\\u53eb\\u4e0d\\u901a\",\"variable\":{\"\\u94f6\\u884c\\u8d26\\u53f7\":\"61214\",\"\\u4f9b\\u7535\\u5355\\u4f4d\":\"\\u8087\\u5e86\\u4f9b\\u7535\\u5c40\",\"\\u6284\\u8868\\u5e95\\u6570\":\"12.48\",\"\\u5e94\\u6536\\u7535\\u8d39\":\"11.5\",\"\\u7528\\u6237\\u540d\\u79f0\":\"\\u738b\\u751f\",\"\\u7528\\u6237\\u7f16\\u53f7\":\"789456\",\"\\u5e94\\u6536\\u7535\\u91cf\":\"120\",\"\\u5ba2\\u6237\\u7ecf\\u7406\\u7535\\u8bdd\\u53f7\\u7801\":\"13100000000\",\"\\u8054\\u7f51\\u94f6\\u884c\":\"\\u5e7f\\u53d1\\u94f6\\u884c\",\"\\u6b20\\u8fdd\\u7ea6\\u91d1\":\"1\",\"\\u7528\\u7535\\u5730\\u5740\":\"\\u8d8a\\u79c0\\u533a\\u6768\\u7b95\\u6751\",\"\\u7535\\u8d39\\u5e74\\u6708\":\"202011\",\"\\u7528\\u7535\\u7c7b\\u5225\":\"\\u5c45\\u6c11\"},\"ttsvoice\":{\"voice\":null,\"volume\":null,\"speech_rate\":null},\"uniqueid\":\"OyUrVTrCcLhPdEnyXtJVmYVHGCTVWDyk\"},{\"id\":\"2\",\"create_time\":\"2020-11-25\n" +
                        "16:46:28\",\"phone\":\"13533154252\",\"call_time\":\"2020-11-25\n" +
                        "16:48:31\",\"call_billsec\":\"0\",\"call_status\":\"3\",\"classification\":\"D\",\"anwser_time\":null,\"hangup_time\":\"2020-11-25\n" +
                        "16:48:32\",\"hangup_cause\":\"\\u547c\\u53eb\\u4e0d\\u901a\",\"variable\":{\"\\u94f6\\u884c\\u8d26\\u53f7\":\"214523\",\"\\u4f9b\\u7535\\u5355\\u4f4d\":\"\\u8087\\u5e86\\u4f9b\\u7535\\u5c40\",\"\\u6284\\u8868\\u5e95\\u6570\":\"14.25\",\"\\u5e94\\u6536\\u7535\\u8d39\":\"10.2\",\"\\u7528\\u6237\\u540d\\u79f0\":\"\\u5218\\u5de5\",\"\\u7528\\u6237\\u7f16\\u53f7\":\"145201\",\"\\u5e94\\u6536\\u7535\\u91cf\":\"14.2\",\"\\u5ba2\\u6237\\u7ecf\\u7406\\u7535\\u8bdd\\u53f7\\u7801\":\"13100000000\",\"\\u8054\\u7f51\\u94f6\\u884c\":\"\\u5efa\\u8bbe\\u94f6\\u884c\",\"\\u6b20\\u8fdd\\u7ea6\\u91d1\":\"1.2\",\"\\u7528\\u7535\\u5730\\u5740\":\"\\u8d8a\\u79c0\\u533a\\u6768\\u7b95\\u6751\",\"\\u7535\\u8d39\\u5e74\\u6708\":\"202011\",\"\\u7528\\u7535\\u7c7b\\u5225\":\"\\u6d4b\\u8bd5\"},\"ttsvoice\":{\"voice\":null,\"volume\":null,\"speech_rate\":null},\"uniqueid\":\"CScXkTaOdJcHNQFjJPFvnbCtdWPAaOkc\"}],\"page\":{\"count\":\"2\",\"page\":0,\"page_size\":\"2\"}}}";

        return JSON.parseObject(str);
    }

    @PostMapping("/yxxt")
    public Map<String, String> testYxxt(@RequestBody YxxtInParam znpcxx) {
        return zncfFeign.fscfdhjgtz(znpcxx);
    }
}